package com.queue.lock;

/**
 * @author: chenhs
 * @date: Created in 11:08 2019/10/12
 **/
public class TestMyBlockingQueue {


    public static void main(String[] args) {

        MyBlockingQueue<Integer> queue = new MyBlockingQueue<>(2);

        for (int i = 0; i < 10; i++) {
            int data = i;
            new Thread(()->{
                try {
                    queue.enqueue(data);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }


        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                try {
                    queue.dequeue();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }
    }

}
